<?php

namespace app\index\controller;

use think\Controller;

/*业务逻辑model*/

use app\common\model\Product as ProductModel;
use app\common\model\Productcate as ProductcateModel;
use app\common\model\News as NewsModel;
use app\common\model\Newscate as NewscateModel;
use app\common\model\Jishu as JishuModel;
use app\common\model\Jishucate as JishucateModel;

class Index extends Controller
{

    /*前台首页*/
    public function index()
    {
        return view();
    }


    /*解决方案*/
    public function jiejuefangan()
    {
        return view();
    }

    /*关于我们*/
    public function aboutus()
    {
        return view();
    }

    /*软件展示*/
    public function softshow()
    {
        /*产品分类*/
        $cates = ProductcateModel::all();
        /*产品数据*/
        $pid = input('pid');
        if ($pid) {
            $map['pid'] = $pid;
        } else {
            $map = '';
        }
        $datas = ProductModel::where($map)->order('id', 'desc')->paginate(6);
        return view('', compact('cates', 'datas'));
    }

    /*软件定制*/
    public function jianzhanfangan()
    {
        return view();
    }

    /*新闻资讯*/
    public function xinwenzixun()
    {

        /*新闻资讯分类*/
        $cates = NewscateModel::all();
        /*新闻资讯数据*/
        $map = array();
        if ($pid = input('pid')) {
            $map['pid'] = $pid;
        }
        $datas = NewsModel::where($map)->order('id', 'desc')->paginate(6);
        return view('', compact('cates', 'datas'));
    }

    /*新闻资讯详情*/
    public function xinwenzixuncontent()
    {
        $id = input('id');
        $data = NewsModel::get($id);
        return view('', compact('data'));
    }

    /*技术支持*/
    public function jishuzhichi()
    {
        /*技术支持分类*/
        $cates = JishucateModel::all();
        /*技术支持数据*/
        $map = array();
        if ($pid = input('pid')) {
            $map['pid'] = $pid;
        }
        if ($keyword = input('keyword')) {
            //搜索时间限制
            session('stime')|| session('stime',time());
            if( session('stime')+10 > time() ){
                $this->error('10秒内只能查找一次。',url('jishuzhichi'));
            }
            session('stime',time());
            $map['title'] = array("like", "%$keyword%");
        }

        $datas = JishuModel::where($map)->order('id', 'desc')->paginate(6);
        return view('', compact('cates', 'datas'));
    }

    /*技术支持详情*/
    public function jishuzhichicontent()
    {
        $id = input('id');
        $data = JishuModel::get($id);
        return view('', compact('data'));
    }


    /*联系我们*/
    public function lianxiwomen()
    {
        return view();
    }
}
